import {http} from '../utils/apiutils.js'
function input(event){
	 let key = event.currentTarget.dataset.key;
	 let val = event.detail.value;
	 this.setData({
		 [key]:val
	 })
}
function picker(event){
	let key = event.currentTarget.dataset.key;
	let range = event.currentTarget.dataset.range
	let val = event.detail.value;
	this.setData({
		[key]:range[val].name
	})
}
function datepicker(event){
	let key = event.currentTarget.dataset.key;
	let val = event.detail.value;
	this.setData({
		[key]:val
	})
}
function getMore(url,params,fn1,fn2){
	if(this.data.loading) return ;
	if(!this.data.hasMore){
		wx.showToast({
		  title: '暂无更多数据',
		  icon:"none"
		})
		return
	}
	http[url](params,res=>{
		let hasMore = true;
		if(res.data.records.length==0){
			hasMore = false
		}
		this.setData({
			loading:false,
			hasMore,
			pageNo:this.data.pageNo*1+1

		})
		fn1&&fn1(res)
	},err=>{
		wx.showToast({
		  title: err,
		  icon:"none"
		})
		this.setData({
			loading:false
		})
	})

}
exports.input = input;
exports.picker = picker;
exports.datepicker = datepicker;
exports.getMore = getMore;
// export default{
// 	input,
// 	picker
// }